package com.qf.sl.youshare.model;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by IDEA
 * User : sl
 * on 2015/2/5.
 * 18:43
 */
public class Product {

    //TODO 成员变量

    private String goodsId;//"goods_id" :  "129",
    private String name;//"name" :  "Dior粉漾魅惑润唇膏",
    private String appGname;//"app_gname" :  "Dior润唇膏",
    private String goodsBrief;//"goods_brief" :  "它可以立即感应双唇的含水量，渐变出适合使用者的不同的红润效果，此自然的红润效果因为是根据每个使用者而调整的。",
    private String goodsStyleName;//"goods_style_name" :  "Dior粉漾魅惑润唇膏",
    private String goodsName;//"goods_name" :  "Dior粉漾魅惑润唇膏",
    private String marketPrice;//"market_price" :  "￥238元",
    private String shopPrice;//"shop_price" :  "￥199元",
    private String type;//"type" :  "0",
    private String addTime;//"add_time" :  "2014-10-17",
    private String promotePrice;//"promote_price" :  "",
    private String goodsThumb;//"goods_thumb" :  "images/201501/thumb_img/129_thumb_G_1420990351514.png",
    private String goodsImg;//"goods_img" :  "images/no_picture.gif",
    private String url;//"url" :  "goods.php?id=129"

    //TODO　解析 JSON 的方法,必须在这个方法的内部

    /**
     * json 数据解析
     *  低耦合
     * @param jsonObject
     */
    public void parseJSON(JSONObject jsonObject){
        if (jsonObject != null) {
            try {
                // 必须存在的数据优先解析,这样保证数据的有效性
                type = jsonObject.getString("type");
                goodsImg = jsonObject.getString("goods_img");
                shopPrice = jsonObject.getString("shop_price");
                name = jsonObject.getString("name");
                goodsId = jsonObject.getString("goods_id");
                goodsThumb = jsonObject.getString("goods_thumb");

                appGname = jsonObject.optString("app_gname");
                goodsName = jsonObject.optString("goods_name");
                goodsBrief = jsonObject.optString("goods_brief");
                goodsStyleName = jsonObject.optString("goods_style_name");
                marketPrice = jsonObject.optString("market_price");
                addTime = jsonObject.optString("add_time");
                promotePrice = jsonObject.optString("promote_price");
                url = jsonObject.optString("url");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    //Get&Set


    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAppGname() {
        return appGname;
    }

    public void setAppGname(String appGname) {
        this.appGname = appGname;
    }

    public String getGoodsBrief() {
        return goodsBrief;
    }

    public void setGoodsBrief(String goodsBrief) {
        this.goodsBrief = goodsBrief;
    }

    public String getGoodsStyleName() {
        return goodsStyleName;
    }

    public void setGoodsStyleName(String goodsStyleName) {
        this.goodsStyleName = goodsStyleName;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getMarketPrice() {
        return marketPrice;
    }

    public void setMarketPrice(String marketPrice) {
        this.marketPrice = marketPrice;
    }

    public String getShopPrice() {
        return shopPrice;
    }

    public void setShopPrice(String shopPrice) {
        this.shopPrice = shopPrice;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getAddTime() {
        return addTime;
    }

    public void setAddTime(String addTime) {
        this.addTime = addTime;
    }

    public String getPromotePrice() {
        return promotePrice;
    }

    public void setPromotePrice(String promotePrice) {
        this.promotePrice = promotePrice;
    }

    public String getGoodsThumb() {
        return goodsThumb;
    }

    public void setGoodsThumb(String goodsThumb) {
        this.goodsThumb = goodsThumb;
    }

    public String getGoodsImg() {
        return goodsImg;
    }

    public void setGoodsImg(String goodsImg) {
        this.goodsImg = goodsImg;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
